#@layout()

#define css()
<style type="text/css">
    #aaa{
        background-image: url(http://47.105.208.60:8080/wechat-api/images/loginbg.png);
        background-position: center center;
        background-repeat: no-repeat;
        background-attachment: fixed;
        background-size: cover;
        text-align:center;
    }
    table#table {
        margin-left:auto;
        margin-right:auto;
        background: #F7F7F7;
        opacity:0.95;
        padding: 25px 15px 25px 10px;
        font: 12px Georgia, "Times New Roman", Times, serif;
        color: #888;
        text-shadow: 1px 1px 1px #FFF;
        border:1px solid #E4E4E4;
        text-align:center;
    }
    h1 {
        font-size: 50px;
        padding: 0px 0px 10px 40px;
        display: block;
        color: slategrey;
        text-align:center;
    }
    button {
        background: #E27575;
        border: none;
        padding: 10px 25px 10px 25px;
        color: #FFF;
        box-shadow: 1px 1px 5px #B6B6B6;
        border-radius: 3px;
        text-shadow: 1px 1px 1px #9E3F3F;
        cursor: pointer;
    }
</style>
#end

#define script()
<script src="https://cdn.staticfile.org/jquery/1.10.2/jquery.min.js">
</script>
<script>
    function select() {
        $.ajax({
            url: "http://47.105.208.60:8080/wechat-api/Blind_date/selectAll"
            //url: "http://localhost:8080/wechat-api/Blind_date/selectAll"
            , dataType: 'json'
            , type: 'POST'
            , success: function (data) {
                console.log("+++++++")
                console.log(data)

                if (data.code == 0) {
                    var infos = data.info;
                    $("tbody").html("");
                    $(infos).each(function () {
                        var content = "<tr>" +
                            "<td class='eid' width='5%' style='table-layout:fixed'>" + this.eid + "</td>" +
                            "<td class='enname' width='5%' style='table-layout:fixed'>" + this.enname + "</td>" +
                            "<td class='name' width='5%' style='table-layout:fixed'>" + this.name + "</td>" +
                            "<td class='citys' width='7%' style='table-layout:fixed'>" + this.citys + "</td>" +
                            "<td class='telephone' width='5%' style='table-layout:fixed'>" + this.telephone + "</td>" +
                            "<td class='profession' width='5%' style='table-layout:fixed'>" + this.profession + "</td>" +
                            "<td class='remark' width='5%' style='table-layout:fixed'>" + this.remark + "</td>" +
                            "<td class='createtime' width='5%'style='table-layout:fixed'>" + this.createtime + "</td>" +
                            "</tr>";
                        $("#tbody").append($(content));
                    });
                    methodExcel('table');
                } else {
                    console.log("========")
                    alert("操作失败");//请求传输失败回调函数
                }
            }
            , error: function (msg) {
                console.log("----------")
                alert(msg); //错误信息

            }
        });
    }
</script>
<script>
    function selectAllDQ() {
        var a;
        $.ajax({
            url: "http://47.105.208.60:8080/wechat-api/Blind_date/selectAllDQ"
            //url: "http://localhost:8080/wechat-api/Blind_date/selectAllDQ"
            , dataType: 'json'
            , type: 'POST'
            , success: function (data) {
                if (data.code == 0) {
                    var infos = data.info;

                    $(infos).each(function () {
                    var content = "<tr id='tr-"+index+"' class='tr'>"+
                        "<td class='eid' width='5%' style='table-layout:fixed'>"+this.eid+"</td>"+
                        "<td class='enname' width='5%' style='table-layout:fixed'>"+this.enname+"</td>"+
                        "<td class='name' width='5%' style='table-layout:fixed'>"+this.name+"</td>"+
                        "<td class='citys' width='7%' style='table-layout:fixed'>"+this.citys+"</td>"+
                        "<td class='telephone' width='5%' style='table-layout:fixed'>"+this.telephone+"</td>"+
                        "<td class='profession' width='5%' style='table-layout:fixed'>"+this.profession+"</td>"+
                        "<td class='remark' width='5%' style='table-layout:fixed'>"+this.remark+"</td>"+
                        "<td class='createtime' width='5%'style='table-layout:fixed'>"+this.createtime+"</td>"+
                        "</tr>";
                        $("#tbody").append($(content));
                    });
                    methodExcel('table');
                } else {
                    console.log("========")
                    alert("操作失败");//请求传输失败回调函数
                }
            }
            , error: function (msg) {
                console.log("----------")
                alert(msg); //错误信息

            }
        });
    }
    function selectAllWS() {
        var a;
        $.ajax({
            url: "http://47.105.208.60:8080/wechat-api/Blind_date/selectAllWS"
            //url: "http://localhost:8080/wechat-api/Blind_date/selectAllWS"
            , dataType: 'json'
            , type: 'POST'
            , success: function (data) {

                if (data.code == 0) {
                    var infos = data.info;
                    $(infos).each(function () {
                        var content = "<tr id='tr-"+index+"' class='tr'>"+
                            "<td class='eid' width='5%' style='table-layout:fixed'>"+this.eid+"</td>"+
                            "<td class='enname' width='5%' style='table-layout:fixed'>"+this.enname+"</td>"+
                            "<td class='name' width='5%' style='table-layout:fixed'>"+this.name+"</td>"+
                            "<td class='citys' width='7%' style='table-layout:fixed'>"+this.citys+"</td>"+
                            "<td class='telephone' width='5%' style='table-layout:fixed'>"+this.telephone+"</td>"+
                            "<td class='profession' width='5%' style='table-layout:fixed'>"+this.profession+"</td>"+
                            "<td class='remark' width='5%' style='table-layout:fixed'>"+this.remark+"</td>"+
                            "<td class='createtime' width='5%'style='table-layout:fixed'>"+this.createtime+"</td>"+
                            "</tr>";
                        $("#tbody").append($(content));
                    })
                    methodExcel('table');
                } else {
                    console.log("========")
                    alert("操作失败");//请求传输失败回调函数
                }
            }
            , error: function (msg) {
                console.log("----------")
                alert(msg); //错误信息

            }
        });
    }
    function selectAllXD() {
        var a;
        $.ajax({
            url: "http://47.105.208.60:8080/wechat-api/Blind_date/selectAllXD"
            //url: "http://localhost:8080/wechat-api/Blind_date/selectAllXD"
            , dataType: 'json'
            , type: 'POST'
            , success: function (data) {
                if (data.code == 0) {
                    var infos = data.info;
                    $(infos).each(function () {
                        var content = "<tr id='tr-"+index+"' class='tr'>"+
                            "<td class='eid' width='5%' style='table-layout:fixed'>"+this.eid+"</td>"+
                            "<td class='enname' width='5%' style='table-layout:fixed'>"+this.enname+"</td>"+
                            "<td class='name' width='5%' style='table-layout:fixed'>"+this.name+"</td>"+
                            "<td class='citys' width='7%' style='table-layout:fixed'>"+this.citys+"</td>"+
                            "<td class='telephone' width='5%' style='table-layout:fixed'>"+this.telephone+"</td>"+
                            "<td class='profession' width='5%' style='table-layout:fixed'>"+this.profession+"</td>"+
                            "<td class='remark' width='5%' style='table-layout:fixed'>"+this.remark+"</td>"+
                            "<td class='createtime' width='5%'style='table-layout:fixed'>"+this.createtime+"</td>"+
                            "</tr>";
                        contentArr += content
                    })
                    methodExcel('table');
                } else {
                    console.log("========")
                    alert("操作失败");//请求传输失败回调函数
                }
            }
            , error: function (msg) {
                console.log("----------")
                alert(msg); //错误信息

            }
        });
    }
    function selectAllXK() {
        var a;
        $.ajax({
            url: "http://47.105.208.60:8080/wechat-api/Blind_date/selectAllXK"
            //url: "http://localhost:8080/wechat-api/Blind_date/selectAllXK"
            , dataType: 'json'
            , type: 'POST'
            , success: function (data) {
                if (data.code == 0) {
                    var infos = data.info;
                    $(infos).each(function () {
                        var content = "<tr id='tr-"+index+"' class='tr'>"+
                            "<td class='eid' width='5%' style='table-layout:fixed'>"+this.eid+"</td>"+
                            "<td class='enname' width='5%' style='table-layout:fixed'>"+this.enname+"</td>"+
                            "<td class='name' width='5%' style='table-layout:fixed'>"+this.name+"</td>"+
                            "<td class='citys' width='7%' style='table-layout:fixed'>"+this.citys+"</td>"+
                            "<td class='telephone' width='5%' style='table-layout:fixed'>"+this.telephone+"</td>"+
                            "<td class='profession' width='5%' style='table-layout:fixed'>"+this.profession+"</td>"+
                            "<td class='remark' width='5%' style='table-layout:fixed'>"+this.remark+"</td>"+
                            "<td class='createtime' width='5%'style='table-layout:fixed'>"+this.createtime+"</td>"+
                            "</tr>";
                        contentArr += content
                    })
                    methodExcel('table');
                } else {
                    console.log("========")
                    alert("操作失败");//请求传输失败回调函数
                }
            }
            , error: function (msg) {
                console.log("----------")
                alert(msg); //错误信息

            }
        });
    }
</script>
<script>
    //导出Excel
    var idTmr;
    function  getExplorer() {
        var explorer = window.navigator.userAgent ;
        //ie
        if (explorer.indexOf("MSIE") >= 0) {
            return 'ie';
        }
        //firefox
        else if (explorer.indexOf("Firefox") >= 0) {
            return 'Firefox';
        }
        //Chrome
        else if(explorer.indexOf("Chrome") >= 0){
            return 'Chrome';
        }
        //Opera
        else if(explorer.indexOf("Opera") >= 0){
            return 'Opera';
        }
        //Safari
        else if(explorer.indexOf("Safari") >= 0){
            return 'Safari';
        }
    }
    function methodExcel(table) {
        if(getExplorer()=='ie')
        {
            var curTbl = document.getElementById(table);
            var oXL = new ActiveXObject("Excel.Application");
            var oWB = oXL.Workbooks.Add();
            var xlsheet = oWB.Worksheets(1);
            var sel = document.body.createTextRange();
            sel.moveToElementText(curTbl);
            sel.select();
            sel.execCommand("Copy");
            xlsheet.Paste();
            oXL.Visible = true;

            try {
                var fname = oXL.Application.GetSaveAsFilename("Excel.xls", "Excel Spreadsheets (*.xls), *.xls");
            } catch (e) {
                print("Nested catch caught " + e);
            } finally {
                oWB.SaveAs(fname);
                oWB.Close(savechanges = false);
                oXL.Quit();
                oXL = null;
                idTmr = window.setInterval("Cleanup();", 1);
            }

        }
        else
        {
            tableToExcel(table)
        }
    }
    function Cleanup() {
        window.clearInterval(idTmr);
        CollectGarbage();
    }
    var tableToExcel = (function() {
        var uri = 'data:application/vnd.ms-excel;base64,',
            template = '<html><head><meta charset="UTF-8"></head><body><table>{table}</table></body></html>',
            base64 = function(s) { return window.btoa(unescape(encodeURIComponent(s))) },
            format = function(s, c) {
                return s.replace(/{(\w+)}/g,
                    function(m, p) { return c[p]; }) }
        return function(table, name) {
            if (!table.nodeType) table = document.getElementById(table)
            var ctx = {worksheet: name || 'Worksheet', table: table.innerHTML}
            window.location.href = uri + base64(format(template, ctx))
        }
    })()

</script>
<script>

   /* window.onload = function chaxun() {
        var date = new Date();
        var y = date.getFullYear();
        var m = date.getMonth() + 1;
        m = m < 10 ? '0' + m : m;
        var d = date.getDate();
        d = d < 10 ? ('0' + d) : d;
        var formatDate = y + '-' + m + '-' + d;

        $.ajax({
            url: "http://47.105.208.60:8080/wechat-api/Blind_date/selectBytime",
            //url:"http://localhost:8080/wechat-api/Blind_date/selectBytime",
            data:formatDate,
            type: 'POST',
            dataType: "json",


            success : function(data) {
                console.log("+++++++++")
                console.log(data)
                if (data.code == 0) {
                    var msg = data.info;
                    $("#xxx").append("&nbsp;&nbsp;&nbsp;<span>"+"今日所有开场宴报名新增:"+msg.today+"</span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span>"+"今日洞桥镇开场宴报名新增:"+msg.dq+"</span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span>"+"今日万市镇开场宴报名新增:"+msg.ws+"</span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span>"+"今日新登镇开场宴报名新增:"+msg.xd+"</span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span>"+"今日胥口镇开场宴报名新增:"+msg.xk+"</span>");
                }

            },error: function(err){
                console.log("----------")
                console.log(err)
            }
        });
    }*/

</script>
#end

#define content()
<div id="aaa"  class="content-wrapper">
    <div>
    <h1 style="text-align: center">开场宴报名统计</h1>
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
    <button type="button" onclick="methodExcel('table')">导出所有数据</button>
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
    <button type="button" onclick="selectAllDQ()">导出洞桥所有数据</button>
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
    <button type="button" onclick="selectAllWS()">导出万市所有数据</button>
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
    <button type="button" onclick="selectAllXD()">导出新登所有数据</button>
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
    <button type="button" onclick="selectAllXK()">导出胥口所有数据</button>
    <br>
    <table border="0" id="xxx" style="height: 100%; width: 100%">

    </table>

    <table border="1" id="table" style="height: 100%; width: 100%;display: none">

        <thead>
        <tr>
            <th>家庭编号</th>
            <th>家庭名称</th>
            <th>报名人</th>
            <th>所在城市</th>
            <th>报名电话</th>
            <th>职业</th>
            <th>备注</th>
            <th>报名时间</th>
        </tr>
        <thead>

        <tbody id="tbody" class="tbody">

        </tbody>
    </table>
    </div>
    <br />
    <br />
    <br />
    <br />
    <br />
    <div align="left" style="margin-left: 150px">
        <button type="button" onclick="selectAllDQ()">随机36户展示</button>
    </div>
</div>
#end